package main

import "fmt"

type Student struct {
	name string
	age int
}

func main() {
	var list = make([]interface{}, 3)
	list[0] = 88.22
	list[1] = 9
	list[2] = &Student{"mike", 12}

	for i, item := range list {
		if v, ok := item.(int); ok {
			fmt.Printf("list[%d] is int, value is %d\n", i, v)
		} else if v, ok := item.(string); ok {
			fmt.Printf("list[%d] is string, value is %s\n", i, v)
		} else if v,ok := item.(*Student); ok { //指针类型判断
			fmt.Printf("list[%d] is *Student, value is %+v\n", i, v)
		} else if v,ok := item.(float64); ok {
			fmt.Printf("list[%d] is float64, values is %3.2f\n", i,v)
		} else if v,ok := item.(float32); ok {
			fmt.Printf("list[%d] is float32, value is %2f\n",i,v)
		}
	}
}
